The future of Popper is here! Floating UI is now available. Get it now!
Popper logo

Tooltip & Popover
Positioning Engine

Weighs just 3 kB!

Star on GitHubDocumentation
Install Popper
npm logo
npm i @popperjs/core
Copied to clipboard!
CDN
https://unpkg.com/@popperjs/core@2
Copied to clipboard!
Don't mind tech-related ads? Consider disabling your ad-blocker to help us!
They are small and unobtrusive.
Alternatively, support us on Open Collective!
Popcorn box
Tip
Popcorn

Placement

Click on the dots to place the tooltip. There are 12 different placements to choose from.

import { createPopper } from '@popperjs/core';
const popcorn = document.querySelector('#popcorn');
const tooltip = document.querySelector('#tooltip');
createPopper(popcorn, tooltip, {
placement: 'top',
});
Edit on CodeSandbox
Popcorn box
Popcorn
sizes
& Price
XXS: $1.99
XS: $2.99
S: $3.99
M: $4.99
L: $5.99
XL: $6.99
XXL: $7.99

Overflow prevention

Scroll the container (or the whole page) to see the tooltip stay within the boundary. Once the opposite edges of the popcorn and tooltip are aligned, the tooltip is allowed to overflow to prevent detachment.

import { createPopper } from '@popperjs/core';
const popcorn = document.querySelector('#popcorn');
const tooltip = document.querySelector('#tooltip');
createPopper(popcorn, tooltip, {
placement: 'right',
});
Edit on CodeSandbox
Popcorn box
Popcorn
New Item

Flipping

Scroll the container (or the whole page) to see the tooltip flip to the opposite side once it's about to overflow the visible area. Once enough space is detected on its preferred side, it will flip back.

import { createPopper } from '@popperjs/core';
const popcorn = document.querySelector('#popcorn');
const tooltip = document.querySelector('#tooltip');
createPopper(popcorn, tooltip);
Edit on CodeSandbox

In a nutshell, Popper:

  • Places your tooltip or popover relative to the reference taking into account their sizes, and positions its arrow centered to the reference.
  • Takes into account the many different contexts it can live in relative to the reference (different offsetParents, different or nested scrolling containers).
  • Keeps your tooltip or popover in view as best as possible. It prevents it from being clipped or cut off (overflow prevention) and changes the placement if the original does not fit (flipping).

Our Sponsors

Popper is proudly sponsored by the following organizations,
join them on Open Collective to support us.

Granular configuration with sensible defaults

Popper aims to "just work" without you needing to configure much. Of course, there are cases where you need to configure Popper beyond its defaults – in these cases, Popper shines by offering high granularity of configuration to fine-tune the position or behavior of your popper.

You can extend Popper with your own modifiers (or plugins) to make your popper work for you, no matter how advanced the scenario.

No compromises

  • No detachment. Position updates take less than a millisecond on average devices. Popper doesn't debounce the positioning updates of the tooltip to the point where it will ever detach from its reference, but this doesn't come at the cost of poor performance.
  • You don't have to change the DOM context of your tooltip or popover element; it will work no matter where your popper and reference elements live, even in the most complex scenarios like nested scrolling containers or alternative offsetParent contexts.
  • Still lightweight. Handling all of this complexity is still done in an efficient manner. The base Popper is only 2 kB minzipped.

Free open-source, used by millions

Popper has billions of hits across the web, is trusted by millions of developers in production, and used in popular libraries like Bootstrap and Material UI.

Support us
Used by Microsoft - Fluent UIUsed by Atlassian - AtlaskitUsed by BootstrapUsed by GitLabUsed by Adobe - @webspectrum componentsUsed by Stack ExchangeUsed by DrupalUsed by Uber - Base WebUsed by TwitchUsed by DiscourseUsed by RedditUsed by Linear

Ready to start?

Start reading Popper's documentation!

© 2024 MIT License